#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
//输入温度
void inputTemps(int temp[], int n);
//输出温度
void displayTemps(int temp[], int n);
//输出高峰
void displayPeaks(int temp[], int n);
//输出崮
void displayFlat(int temp[], int n);
int main()
{
    int temps[100];
    inputTemps(temps, 15);
    displayTemps(temps, 15);
    displayPeaks(temps, 15);
    displayFlat(temps, 15);
}

void displayFlat(int temp[], int n)
{
    int flag = 1;
    int max = 1;
    for (int i = 1; i < n; i++)
    {
        if (temp[i] == temp[i - 1])
        {
            flag++;
            if (flag > max)
            {
                max = flag;
            }
        }
        else
        {
            flag = 1;
        }
    }
    cout << "最长的崮:  " << max << endl;
}

void displayPeaks(int temp[], int n)
{
    int flag = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (temp[i] > temp[i + 1] && temp[i] > temp[i - 1])
        {
            cout << "Max at day " << i + 1 << " is: " << temp[i] << endl;
            flag++;
        }
    }
    if (flag == 0)
    {
        cout << "没有峰值" << endl;
    }
}

void displayTemps(int temp[], int n)
{
    int max = 0;
    for (int i = 0; i < n; i++)
    {
        if(abs(temp[i]) > max){
         max = abs(temp[i]);
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        if (temp[i] > 0)
        {

            cout << setw(4) << i + 1 << setw(max+1) << "|";
            for (int j = 0; j < temp[i]; j++)
            {
                cout << "*";
            }
            cout << endl;
        }
        else
        {
            cout << setw(4) << i + 1 << setw(max+1 + temp[i]);
            for (int j = 0; j < -temp[i]; j++)
            {
                cout << "*";
            }
            cout << "|" << endl;
        }
    }
}

void inputTemps(int temp[], int n)
{
    cout << "输入15个温度:" << endl;
    for (int i = 0; i < n; i++)
    {
        cin >> temp[i];
    }
}